package pri.damai.xiaowu.auth.controller;

import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pri.damai.xiaowu.auth.manager.UserManager;
import pri.damai.xiaowu.auth.security.model.LoginData;
import pri.damai.xiaowu.auth.security.model.UserInfo;
import pri.damai.xiaowu.auth.vo.LoginSuccessVO;
import pri.damai.xiaowu.common.core.vo.ResultVO;
import pri.damai.xiaowu.common.log.anno.XiaoWuLog;
import pri.damai.xiaowu.usercenter.client.UserCenterFeignClient;
import pri.damai.xiaowu.usercenter.common.dto.LoginDTO;
import pri.damai.xiaowu.usercenter.common.dto.UserDTO;

import javax.annotation.Resource;

/**
 *
 * @Desc
 * @Author DaMai
 * @Date 2021/10/14 16:10
 * 但行好事，莫问前程。
 */
@XiaoWuLog
@Slf4j
@Api(tags = "test")
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    UserManager userManager;
    @Resource
    UserCenterFeignClient userCenterFeignClient;

    @Operation(summary = "测试接口")
    @PostMapping("/test")
    public ResultVO<LoginSuccessVO> test(@RequestBody LoginData loginData) {
        return ResultVO.success(new LoginSuccessVO());
    }



    @Operation(summary = "测试接口")
    @PostMapping("test1")
    public ResultVO<UserInfo> test1(@RequestBody LoginDTO loginDTO) {
        //UserInfo user = userManager.getUser(loginDTO.getPhone());
        ResultVO<UserDTO> user = userCenterFeignClient.getUser(loginDTO);
        log.info("{}",user);
        return ResultVO.success();
    }

}
